<!DOCTYPE html>
<html>
<head>
	<title>登录</title>
</head>
<body>
<form onsubmit="return check()">
	<label>用户名</label><input id="username" type="text" name="username">
	<label>密码</label><input id="password" type="password" name="password">
	<input type="submit" value="登录">
</form>

	<script type="text/javascript">
		
		function check(){
			var username = document.getElementById("username").value;
			var password = document.getElementById("password").value;
			if(!username){
				alert("用户名不能为空！");
				return false;
			}
			if(!password){
				alert("密码不能为空！");
				return false;
			}
			return true
		}
	</script>
</body>
</html>